class StockQuotesController < ApplicationController
  
  # return all StockQuotes
  def find_all
    respond_to do |format|
      format.amf  { render :amf => StockQuotes.find(:all) }
    end
  end
  
  # return a single StockQuotes by id
  # expects id in params[0]
  def find_by_id
    respond_to do |format|
      format.amf { render :amf => StockQuotes.find(params[0]) }
    end
  end

  # saves new or updates existing StockQuotes
  # expect params[0] to be incoming StockQuotes
  def save
    respond_to do |format|
      format.amf do
        @stock_quote = params[0][:stock_quote]

        if @stock_quote.save
          render :amf => @stock_quote
        else
          render :amf => FaultObject.new(@stock_quote.errors.full_messages.join('\n'))
        end
      end
    end
  end



  def update
    respond_to do |format|
      format.amf do
        @stock_quote =  StockQuotes.find(params[:id])
        
         if @stock_quote.update_attributes(params[0][:stock_quote].attributes)
          render :amf => @stock_quote
        else
          render :amf => FaultObject.new(@stock_quote.errors.full_messages.join('\n'))
        end
      end
    end
  end




  # destroy a StockQuotes
  # expects id in params[0]
  def destroy
    respond_to do |format|
      format.amf do
        @stock_quote = StockQuotes.find(params[0][:id])
        @stock_quote.destroy

        render :amf => true
      end
    end
  end


end
